home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2004 #2 / Amiga Plus CD - 2004 - No. 02.iso / AmiSoft / Gfx / conv / GS8gui.lha / GS8gui / GS8gui.rexx < prev    next >
OS/2 REXX Batch file  |  2004-01-06  |  39KB  |  1,440 lines

  1. /*
  2. ** -----------------------------------------------
  3. **  $VER: GS8gui V0.06 (6 Jan 2004)
  4. **  ©2003-04 Michael Merkel
  5. ** -----------------------------------------------
  6. */
  7.  
  8. SIGNAL ON SYNTAX
  9. SIGNAL ON HALT
  10. SIGNAL ON ERROR
  11. SIGNAL ON BREAK_C
  12. OPTIONS RESULTS
  13.  
  14. /*
  15. TRACE ALL
  16. */
  17. global.DEBUG = 1
  18.  
  19. Call Init       /* init globals */
  20.  
  21. Call CreateApp  /* build and open window and stuff */
  22. Call HandleApp  /* event loop */
  23.  
  24. EXIT
  25.  
  26. /*===========================================================================*/
  27. /*===========================================================================*/
  28. /*===========================================================================*/
  29.  
  30. /* /// Init( )
  31. */
  32. Init:
  33.     /* first of all add the needed libraries */
  34.     IF ~show("L","rmh.library")
  35.     THEN IF ~AddLib("rmh.library", 0, -30) THEN EXIT
  36.  
  37.     IF RMH_AddLibrary('rxmui.library')~=0
  38.     THEN DO
  39.         Call RMH_EasyRequest("Couldn't open" result, "Error opening the library", 'Quit')
  40.         Signal Quit
  41.     END
  42.  
  43.     IF RMH_AddLibrary('rxasl.library')~=0
  44.     THEN DO
  45.         Call RMH_EasyRequest("Couldn't open" result, "Error opening the library", 'Quit')
  46.         Signal Quit
  47.     END
  48.  
  49.     Call RMH_MacroEnv('Macro','ProgDir')
  50.  
  51.     /* set globals and defaults (including settings) */
  52.     Call SetDefaults
  53.  
  54.     /* check for existing gs8 executeable */
  55.     IF Exists(global.gs8) = 0
  56.     THEN DO
  57.         Call RMH_EasyRequest("Couldn't open gs8 executeable:" global.gs8 "- Check Tooltype!", "gs8 executeable not found", 'Quit')
  58.         Signal Quit
  59.     END
  60.  
  61.     /* set DEBUG mode */
  62.     IF global.DEBUG = const.bool.TRUE
  63.     THEN Call rxMuiOpt("DEBUGMODE SHOWERR")
  64.  
  65. Return
  66. /* /// */
  67. /* /// CreateApp( )
  68. */
  69. CreateApp:
  70.     /* build GUI */
  71.     Call BuildGUI
  72.  
  73.     /* default settings */
  74.     Call LoadProject( )
  75.  
  76.     /* open window */
  77.     Call Set("muiWin", "OPEN", 1)
  78.     Call GetAttr("muiWin", "OPEN", "o")
  79.     IF (o = 0)
  80.     THEN DO
  81.         Call RMH_EasyRequest("Can not open window -> QUIT", "ADFMaker", 'Quit')
  82.         Signal Quit
  83.     END
  84.  
  85.     /* set defaults to window */
  86.     Call Set("muiWin", "SLEEP", 1)
  87.     Call PrefsWindowSet()
  88.     Call Set("muiWin", "SLEEP", 0)
  89.  
  90. Return
  91. /* /// */
  92. /* /// BuildGUI()
  93. */
  94. BuildGUI:
  95.     PROCEDURE expose global. const. prefs.
  96.  
  97.     /*
  98.     ** Create the rxMUI GUI
  99.     ** --------------------
  100.     */
  101.  
  102.     /* first of all the let's define the application object */
  103.     muiApp.Title               = const.info.muiName
  104.     muiApp.Version             = "$VER: "|| const.info.muiVersion ||' ('|| const.info.muiDate ||')'
  105.     muiApp.Copyright           = const.info.muiCopy
  106.     muiApp.Author              = const.info.muiAuthor
  107.     muiApp.Description         = const.info.muiDescription
  108.     muiApp.Base                = const.info.muiName
  109.     muiApp.diskobject          = const.info.muiName
  110.     muiApp.ctrlc               = const.bool.TRUE
  111.     muiApp.menustrip           = "muiMenuStrip"
  112.     muiApp.subwindow           = "muiWin"
  113.  
  114.     /* let's define the window */
  115.     muiWin.ID                   = "MAIN"
  116.     muiWin.Title                = const.info.muiName const.info.muiVersion ||' ('|| const.info.muiDate ||') - '|| const.info.muiCopy
  117.     muiWin.Contents             = "muiMainGroup"
  118.  
  119.     /* define the menu */
  120.     muiMenuStrip.0 = "muiMenuProject"
  121.         muiMenuProject.Title    = "Project"
  122.         muiMenuProject.Class    = "MENU"
  123.         muiMenuProject.0        = MenuItem("muiProjectOpen",    "Open...",            "O"    )
  124.         muiMenuProject.1        = MenuItem("muiProjectSave",    "Save",                "S"    )
  125.         muiMenuProject.2        = MenuItem("muiProjectSaveAs",    "Save As...",        "A"    )
  126.         muiMenuProject.3        = MenuItem("",                    "BAR"                    )
  127.         muiMenuProject.4        = MenuItem("muiMenuQuit",        "Quit",                "Q"    )
  128.  
  129.     muiMenuStrip.1 = "muiMenuPrefs"
  130.         muiMenuPrefs.Title        = "Prefs"
  131.         muiMenuPrefs.Class        = "MENU"
  132.         muiMenuPrefs.0            = MenuItem("muiPrefsLast",        "Last saved",        "L" )
  133.         muiMenuPrefs.1            = MenuItem("",                    "BAR"                    )
  134.         muiMenuPrefs.2            = MenuItem("muiPrefsMUI",        "MUI...",            "M"    )
  135.  
  136.     muiMenuStrip.2 = "muiMenuAbout"
  137.         muiMenuAbout.Title        = "?"
  138.         muiMenuAbout.Class        = "MENU"
  139.         muiMenuAbout.0            = MenuItem("muiMenuAboutME",    "About...",            "?"    )
  140.         muiMenuAbout.1            = MenuItem("",                    "BAR"                    )
  141.         muiMenuAbout.2            = MenuItem("muiMenuAboutrxMUI",    "About RxMUI..."        )
  142.         muiMenuAbout.3            = MenuItem("muiMenuAboutMUI",    "About MUI..."            )
  143.  
  144.     res = NewObj("MENUSTRIP", "muiMenuStrip")
  145.     IF (res ~= 0)
  146.     THEN Call Err(res)
  147.  
  148.     /* let's define the window content */
  149.     muiMainGroup.0            = "muiGroup0"
  150.         muiGroup0.Class            = "TheBar"
  151.         muiGroup0.Horiz            = 1
  152.         muiGroup0.PicsDrawer    = "Pics"
  153.  
  154.         /* Define the pics */
  155.         muiGroup0.Pics.0        = "Display"
  156.         muiGroup0.Pics.1        = "Print"
  157.         muiGroup0.Pics.2        = "Convert"
  158. /*
  159.         muiGroup0.Pics.3        = "Prefs"
  160. */
  161.  
  162.         /* Define the buttons */
  163.  
  164.         /* ID:0 - Image: "display" */
  165.         muiGroup0.0.ID      = 0
  166.         muiGroup0.0.Img      = 0
  167.         muiGroup0.0.Text  = "Display"
  168.  
  169.         /* ID:1 - Image: "print" */
  170.         muiGroup0.1.ID      = 1
  171.         muiGroup0.1.Img      = 1
  172.         muiGroup0.1.Text  = "Print"
  173.  
  174.         /* ID:2 - Image: "convert" */
  175.         muiGroup0.2.ID      = 2
  176.         muiGroup0.2.Img      = 2
  177.         muiGroup0.2.Text  = "Convert"
  178.  
  179.         /* spacer */
  180.         muiGroup0.3.Img="Bar"
  181. /*
  182.         /* ID:4 - Image: "ENV Prefs" */
  183.         muiGroup0.4.ID      = 4
  184.         muiGroup0.4.Img      = 3
  185.         muiGroup0.4.Text  =    "Prefs"
  186. */
  187.  
  188.     muiMainGroup.1        = "muiGroupPage00"
  189.         muiGroupPage00.Class    = "GROUP"
  190.         muiGroupPage00.Horiz    = 0
  191.  
  192.         muiGroupPage00.0        = VSpace(10)
  193.  
  194.         muiGroupPage00.1        = "muiFile"
  195.             muiFile.Class            = "GROUP"
  196.             muiFile.Horiz            = "1"
  197.             muiFile.Columns            = "2"
  198.             muiFile.0                = Label(ParseText("%bPostscript/PDF file:%n"))
  199.             muiFile.1                = "g_psfile"
  200.                 g_psfile.Class            = "POPASL"
  201.                 g_psfile.Type            = "FILE"
  202.                 g_psfile.Title            = "PostScript/PDF file..."
  203.                 g_psfile.PositiveText    = "Ok"
  204.                 g_psfile.NegativeText    = "Cancel"
  205.                 g_psfile.RejectIcons    = 1
  206.                     g_psfilename.ObjectID    = "GSPS"
  207.                     g_psfilename.ShortHelp    = ParseText("%bPDF%n or %bPS%n file to work on")
  208.                 g_psfile.String            = String("g_psfilename",,"document.PDF")
  209.                 Call AddGUIGadget( "g_psFileName", "GSPS", "CONTENTS" )
  210.  
  211.         muiGroupPage00.2        = VSpace(10)
  212.  
  213.         muiGroupPage00.3        = "muiSettings"
  214.             muiSettings.Class        = "REGISTER"
  215.             muiSettings.Titles        = "display settings|print settings|convert settings"
  216.  
  217.             /* DISPLAY SETTINGS */
  218.             muiSettings.0            = "muiSettingsDisplay"
  219.                 muiSettingsDisplay.Class    = "GROUP"
  220.                 muiSettingsDisplay.0        = "muiSD01"
  221.                     muiSD01.Class                = "GROUP"
  222.                     muiSD01.Frame                = "GROUP"
  223.                     muiSD01.FrameTitle            = "General display settings"
  224.                     muiSD01.Columns                = "2"
  225.                     muiSD01.0                    = Label(ParseText("%uR%nesolution:"))
  226.                         g_d_dpi.ObjectID = "GSDR"
  227.                     muiSD01.1                    = MakeObj("g_d_dpi", "Slider", "R", "50", "600", "100", "%ld dpi")
  228.                     Call AddGUIGadget( "g_d_dpi", "GSDR", "VALUE" )
  229.                     muiSD01.2                    = Label(ParseText("P%ua%nge:"))
  230.                         g_d_page.ObjectID    = "GSDA"
  231.                         g_d_page.ShortHelp    = ParseText("Only works for PDF files! When used for PS files this has NO effect.\nActually the %ucomplete%n PS file is viewed - be carefull!")
  232.                     muiSD01.3                    = MakeObj("g_d_page", "Slider", "P", "1", "100", "1", "Page %ld")
  233.                     Call AddGUIGadget( "g_d_page", "GSDA", "VALUE" )
  234.                     muiSD01.4                    = Label(ParseText("%uM%nethod:"))
  235.                         g_d_method.ObjectID        = "GSDM"
  236.                         g_d_method.ShortHelp    = ParseText("%bInternal%n will use the phantastic WHOOSH display driver.\n%bExternal%n will convert the file to a picture and show this instead.")
  237.                     muiSD01.5                    = MakeObj("g_d_method","Cycle", "internal|external (bitmap)", "M", "0")
  238.                     Call AddGUIGadget( "g_d_method", "GSDM", "ACTIVE" )
  239.                 /* INTERNAL VIEWER */
  240.                 muiSettingsDisplay.1        = "muiSD02"
  241.                     muiSD02.Class                = "GROUP"
  242.                     muiSD02.Frame                = "GROUP"
  243.                     muiSD02.FrameTitle            = "Internal viewer"
  244.                     muiSD02.Columns                = "2"
  245.                     muiSD02.0                    = Label(ParseText("%uD%nevice:"))
  246.                         g_d_device.ObjectID = "GSDD"
  247.                     muiSD02.1                    = MakeObj("g_d_device","Cycle", "24 bit|8 bit grey|1 bit b/w", "D", "0")
  248.                     Call AddGUIGadget( "g_d_device", "GSDD", "ACTIVE" )
  249.                     muiSD02.2                    = Label(ParseText("Use own %us%ncreen"))
  250.                     muiSD02.3                    = "muiSD020"
  251.                         muiSD020.Class                = "GROUP"
  252.                         muiSD020.Horiz                = "1"
  253.                         muiSD020.Horiz                = "1"
  254.                             g_d_screen.ObjectID = "GSDU"
  255.                         muiSD020.0                    = Checkmark("g_d_screen", 0)
  256.                         Call AddGUIGadget( "g_d_screen", "GSDU", "SELECTED" )
  257.                         muiSD020.1                    = Label(ParseText("like WorkBench"))
  258.                             g_d_screenwb.ObjectID = "GSDW"
  259.                         muiSD020.2                    = Checkmark("g_d_screenwb", 0)
  260.                         Call AddGUIGadget( "g_d_screenwb", "GSDW", "SELECTED" )
  261.                         muiSD020.3                    = HSpace( )
  262.                 /* EXTERNAL VIEWER */
  263.                 muiSettingsDisplay.2        = "muiSD03"
  264.                     muiSD03.Class                = "GROUP"
  265.                     muiSD03.Disabled            = 1
  266.                     muiSD03.Frame                = "GROUP"
  267.                     muiSD03.FrameTitle            = "External viewer (bitmap)"
  268.                     muiSD03.Columns                = "2"
  269.                     muiSD03.0                    = Label(ParseText("External viewer:"))
  270.                     muiSD03.1                    = "muiEXViewer"
  271.                         muiEXViewer.Class              = "POPASL"
  272.                         muiEXViewer.Type              = "FILE"
  273.                         muiEXViewer.Title              = "External viewer..."
  274.                         muiEXViewer.PositiveText      = "Ok"
  275.                         muiEXViewer.NegativeText      = "Cancel"
  276.                         muiEXViewer.RejectIcons          = 1
  277.                             g_d_ex_viewer.ObjectID = "GSDE"
  278.                         muiEXViewer.String              = String("g_d_ex_viewer")
  279.                         Call AddGUIGadget( "g_d_ex_viewer", "GSDE", "CONTENTS" )
  280.  
  281.                     muiSD03.2                    = Label(ParseText("%uB%nitmap format:"))
  282.                         g_d_bm_format.ObjectID = "GSDF"
  283.                     muiSD03.3                    = MakeObj("g_d_bm_format", "Cycle", "JPEG|PNG|TIFF", "B", "0")
  284.                     Call AddGUIGadget( "g_d_bm_format", "GSDF", "ACTIVE" )
  285.                     muiSD03.4                    = Label(ParseText("%uQ%nuality:"))
  286.                         g_d_bm_quality.ObjectID = "GSDQ"
  287.                     muiSD03.5                    = MakeObj("g_d_bm_quality", "Cycle", "24 bit color|8 bit grey|1 bit b/w", "Q", "0")
  288.                     Call AddGUIGadget( "g_d_bm_quality", "GSDQ", "ACTIVE" )
  289.                     muiSD03.6                    = Label(ParseText("File path:"))
  290.                     muiSD03.7                    = "muiBMPath"
  291.                         muiBMPath.Class                = "POPASL"
  292.                         muiBMPath.Type                = "FILE"
  293.                         muiBMPath.DrawersOnly        = "1"
  294.                         muiBMPath.Title                = "File path for bitmap..."
  295.                         muiBMPath.PositiveText        = "Ok"
  296.                         muiBMPath.NegativeText        = "Cancel"
  297.                         muiBMPath.RejectIcons        = 1
  298.                             g_d_bm_path.ObjectID = "GSDP"
  299.                         muiBMPath.String            = String("g_d_bm_path")
  300.                         Call AddGUIGadget( "g_d_bm_path", "GSDP", "CONTENTS" )
  301.  
  302.             /* PRINT SETTINGS */
  303.             muiSettings.1            = "muiSettingsPrint"
  304.                 muiSettingsPrint.Class        = "GROUP"
  305.                 muiSettingsPrint.0            = "muiSP01"
  306.                     muiSP01.Class                = "GROUP"
  307.                     muiSP01.Frame                = "GROUP"
  308.                     muiSP01.FrameTitle            = "Sending file to printer"
  309.                     muiSP01.Columns                = "2"
  310.                     muiSP01.0                    = Label(ParseText("%uR%nesolution:"))
  311.                         g_p_dpi.ObjectID    = "GSPR"
  312.                         g_p_dpi.Stringify    = "PARSE ARG val; IF (val = 0) THEN RETURN 'default';ELSE RETURN val 'dpi'"
  313.                         g_p_dpi.ShortHelp    = ParseText("Use %bdefault%n when using TurboPrint:\nTurboPrint resolution settings are used instead.")
  314.                     muiSP01.1                    = MakeObj("g_p_dpi", "Slider", "R", "0", "600", "0", "%ld dpi")
  315.                     Call AddGUIGadget( "g_p_dpi", "GSPR", "VALUE" )
  316.                     muiSP01.2                    = Label(ParseText("%uF%nrom:"))
  317.                         g_p_page1.ObjectID = "GSP1"
  318.                     muiSP01.3                    = MakeObj("g_p_page1", "Slider", "1", "1", "100", "1", "Page %ld")
  319.                     Call AddGUIGadget( "g_p_page1", "GSP1", "VALUE" )
  320.                     muiSP01.4                    = Label(ParseText("%uT%no:"))
  321.                         g_p_page2.ObjectID = "GSP2"
  322.                     muiSP01.5                    = MakeObj("g_p_page2", "Slider", "2", "1", "100", "1", "Page %ld")
  323.                     Call AddGUIGadget( "g_p_page2", "GSP2", "VALUE" )
  324.                 muiSettingsPrint.1            = "muiSP02"
  325.                     muiSP02.Class                = "GROUP"
  326.                     muiSP02.Frame                = "GROUP"
  327.                     muiSP02.FrameTitle            = "Output device"
  328.                     muiSP02.Columns                = "2"
  329.                     muiSP02.0                    = Label(ParseText("%uD%nevice:"))
  330.                         g_p_device.ObjectID = "GSPD"
  331.                     muiSP02.1                    = MakeObj("g_p_device","Cycle", "tp24|tp8g|tp1", "D", "0")
  332.                     Call AddGUIGadget( "g_p_device", "GSPD", "ACTIVE" )
  333.             
  334.             /* CONVERT SETTINGS */
  335.             muiSettings.2            = "muiSettingsConvert"
  336.                 muiSettingsConvert.Class    = "GROUP"
  337.                 muiSettingsConvert.0        = "muiSC01"
  338.                     muiSC01.Class                = "GROUP"
  339.                     muiSC01.Frame                = "GROUP"
  340.                     muiSC01.FrameTitle            = "Convert PS/PDF file"
  341.                     muiSC01.Columns                = "2"
  342.                     muiSC01.0                    = Label(ParseText("%uR%nesolution:"))
  343.                         g_c_dpi.ObjectID    = "GSCR"
  344.                         g_c_dpi.Stringify    = "PARSE ARG val; IF (val = 0) THEN RETURN 'default';ELSE RETURN val 'dpi'"
  345.                     muiSC01.1                    = MakeObj("g_c_dpi", "Slider", "R", "0", "600", "0", "%ld dpi")
  346.                     Call AddGUIGadget( "g_c_dpi", "GSCR", "VALUE" )
  347.                     muiSC01.2                    = Label(ParseText("%uF%nrom:"))
  348.                         g_c_page1.ObjectID = "GSC1"
  349.                     muiSC01.3                    = MakeObj("g_c_page1", "Slider", "1", "1", "100", "1", "Page %ld")
  350.                     Call AddGUIGadget( "g_c_page1", "GSC1", "VALUE" )
  351.                     muiSC01.4                    = Label(ParseText("%uT%no:"))
  352.                         g_c_page2.ObjectID = "GSC2"
  353.                     muiSC01.5                    = MakeObj("g_c_page2", "Slider", "2", "1", "100", "1", "Page %ld")
  354.                     Call AddGUIGadget( "g_c_page2", "GSC2", "VALUE" )
  355.                 /* INTERNAL DEVICE */
  356.                 muiSettingsConvert.1        = "muiSC02"
  357.                     muiSC02.Class                = "GROUP"
  358.                     muiSC02.Frame                = "GROUP"
  359.                     muiSC02.FrameTitle            = "Output device"
  360.                     muiSC02.Columns                = "2"
  361.                     muiSC02.0                    = Label(ParseText("%uD%nevice:"))
  362.                         g_c_device.ObjectID = "GSCD"
  363.                     muiSC02.1                    = MakeObj("g_c_device","Cycle", "PDF|EPS|PS|TIFF|PNG|JPEG", "D", "0")
  364.                     Call AddGUIGadget( "g_c_device", "GSCD", "ACTIVE" )
  365.                     muiSC02.2                    = Label(ParseText("Destination file:"))
  366.                     muiSC02.3                    = "muiConvFile"
  367.                         muiConvFile.Class            = "POPASL"
  368.                         muiConvFile.Type            = "FILE"
  369.                         muiConvFile.Title            = "Destination file..."
  370.                         muiConvFile.PositiveText    = "Ok"
  371.                         muiConvFile.NegativeText    = "Cancel"
  372.                         muiConvFile.RejectIcons        = 1
  373.                             g_c_conv_file.ObjectID        = "GSCF"
  374.                             g_c_conv_file.ShortHelp        = ParseText("%b\%d%n inside the filename will be\nreplaced by the page number\n(see gs8 documentation for more info)")
  375.                         muiConvFile.String            = String("g_c_conv_file")
  376.                         Call AddGUIGadget( "g_c_conv_file", "GSCF", "CONTENTS" )
  377.  
  378.             /*----------------------------------------------------------*/
  379.  
  380.     /* create all */
  381.     Call NewObj("APPLICATION","muiApp")
  382.     global.ActiveWin = global.TRUE
  383.     global.ActiveApp = global.TRUE
  384.  
  385.     Call BuildActionWIN()
  386.  
  387.     /* window close gadget means quit... */
  388.     Call Notify("muiWin",    "CLOSEREQUEST", const.bool.TRUE, "muiApp", "RETURNID", "QUIT")
  389.  
  390.     /* Buttons... */
  391.     Call TheBarNotify("muiGroup0", "0", "PRESSED", 0, "_APP", "RETURN", "DO_DISPLAY")
  392.     Call TheBarNotify("muiGroup0", "1", "PRESSED", 0, "_APP", "RETURN", "DO_PRINT")
  393.     Call TheBarNotify("muiGroup0", "2", "PRESSED", 0, "_APP", "RETURN", "DO_CONVERT")
  394.  
  395.  
  396.     /* Menu events... */
  397.     Call Notify("muiProjectOpen",        "MENUTRIGGER", "EVERYTIME", "muiApp", "RETURNID")
  398.     Call Notify("muiProjectSave",        "MENUTRIGGER", "EVERYTIME", "muiApp", "RETURNID")
  399.     Call Notify("muiProjectSaveAs",        "MENUTRIGGER", "EVERYTIME", "muiApp", "RETURNID")
  400.     Call Notify("muiMenuQuit",            "MENUTRIGGER", "EVERYTIME", "muiApp", "RETURNID")
  401.  
  402.     Call Notify("muiPrefsLast",            "MENUTRIGGER", "EVERYTIME", "muiApp", "RETURNID")
  403.     Call Notify("muiPrefsMUI",            "MENUTRIGGER", "EVERYTIME", "muiApp", "OpenConfigWindow")
  404.  
  405.     Call Notify("muiMenuAboutME",        "MENUTRIGGER", "EVERYTIME", "muiApp", "ABOUT",      "muiWin")
  406.     Call Notify("muiMenuAboutrxMUI",    "MENUTRIGGER", "EVERYTIME", "muiApp", "ABOUTRXMUI", "muiWin")
  407.     Call Notify("muiMenuAboutMUI",        "MENUTRIGGER", "EVERYTIME", "muiApp", "ABOUTMUI",   "muiWin")
  408.  
  409.     Call Notify("g_d_method", "ACTIVE", 0, "muiSD02", "SET", "DISABLED", 0)
  410.     Call Notify("g_d_method", "ACTIVE", 0, "muiSD03", "SET", "DISABLED", 1)
  411.     Call Notify("g_d_method", "ACTIVE", 1, "muiSD02", "SET", "DISABLED", 1)
  412.     Call Notify("g_d_method", "ACTIVE", 1, "muiSD03", "SET", "DISABLED", 0)
  413.  
  414.     Call Notify("g_psfilename",        "CHANGED", "EVERYTIME", "muiAPP", "RETURN", "PSFILECHANGE")
  415.     Call Notify("g_c_conv_file",    "CHANGED", "EVERYTIME", "muiAPP", "RETURN", "CONVFILECHANGE")
  416.  
  417.     Call Notify("g_d_screen", "SELECTED", 1, "g_d_screenwb", "SET", "DISABLED", 0)
  418.     Call Notify("g_d_screen", "SELECTED", 0, "g_d_screenwb", "SET", "DISABLED", 1)
  419.  
  420.     Call SetAttr("g_d_screenwb", "DISABLED", 1)
  421.  
  422. Return
  423. /* /// */
  424. /* /// BuildActionWin()
  425. */
  426. BuildActionWin:
  427.     PROCEDURE EXPOSE global. const.
  428.  
  429.     actionWin.ID                = "AWin"
  430.     actionWin.SizeGadget        = 1
  431.     actionWin.Background        = "TextBack"
  432.     actionWin.Title                = "please wait..."
  433.     actionWin.Contents              = "infoGroup"
  434.         infoGroup.0                    = "infoTitle"
  435.             infoTitle.Class                = "TEXT"
  436.             infoTitle.Font                = "Big"
  437.             infoTitle.Contents            = ParseText("%c  --== %bGhostscript 8 working%n ==--  ")
  438.         infoGroup.1                = "actionInfo1"
  439.             actionInfo1.Class        = "TEXT"
  440.             actionInfo1.Font        = "Tiny"
  441.             actionInfo1.Contents    = ParseText("%baction...%n ")
  442.         infoGroup.2                = "actionInfo2"
  443.             actionInfo2.Class        = "TEXT"
  444.             actionInfo2.Font        = "Tiny"
  445.             actionInfo2.Contents    = ParseText("%b...%n ")
  446.         infoGroup.3                = HBAR()
  447.         infoGroup.4                = VSPACE(2)
  448.         infoGroup.5                = Text("intro", "please wait...", "none", "none")
  449.         infoGroup.6                = MakeObj("ActionBusy", "Busy")
  450.         infoGroup.7                = MakeObj('infoGroupH1', "HCenter", Button("ActionCancel", "Cancel..."))
  451.  
  452.     IF NewObj("Window", "actionWin") > 0
  453.     THEN DO
  454.         Call Failure("Can't create progress window")
  455.         Return
  456.     END
  457.  
  458.     Call Notify("actionWin",       "CLOSEREQUEST", 1, "muiAPP", "RETURN", "ACTION_QUIT")
  459.     Call Notify("ActionCancel", "PRESSED",         0, "muiAPP", "RETURN", "ACTION_CANCEL")
  460.  
  461.     Call Add("muiApp", "actionWin")
  462.     Call Set("actionWin","open",0)
  463.  
  464. Return
  465. /* /// */
  466.  
  467. /* /// HandleApp( )
  468. */
  469. HandleApp:
  470.  
  471.     /* this is the standard cycle to handle an application */
  472.     sig_CTRL_C = 2**12
  473.     s = sig_CTRL_C
  474.  
  475.     DO FOREVER
  476.         h.event = ''
  477.         Call NewHandle("muiAPP", "H", s)
  478.  
  479.         IF ( and(h.signals, sig_CTRL_C) > 0 )
  480.         THEN Signal QUIT
  481.  
  482.         SELECT
  483.             /* WINDOW CLOSE */
  484.             WHEN (Upper(h.event) = "QUIT")
  485.             THEN DO
  486.                 Call SaveProject( "" )
  487.                 Signal QUIT
  488.                 EXIT
  489.             END
  490.  
  491.             /* QUIT */
  492.             WHEN (Upper(h.event) = "MUIMENUQUIT")
  493.             THEN DO
  494.                 IF ( EasyRequest('Really Quit?', const.info.muiName, 'Yes|NO') = 1 )
  495.                 THEN DO
  496.                     Call SaveProject( "" )
  497.                     Signal QUIT
  498.                     EXIT
  499.                 END
  500.             END
  501.  
  502.             /* open project file */
  503.             WHEN (Upper(h.event) = "MUIPROJECTOPEN")
  504.             THEN DO
  505.                 project = GetFileName( )
  506.                 Call LoadProject( project )
  507.             END
  508.  
  509.             /* save project file */
  510.             WHEN (Upper(h.event) = "MUIPROJECTSAVE")
  511.             THEN DO
  512.                 Call SaveProject( "" )
  513.             END
  514.  
  515.             /* save project file as */
  516.             WHEN (Upper(h.event) = "MUIPROJECTSAVEAS")
  517.             THEN DO
  518.                 project = GetFileName( )
  519.                 Call SaveProject(project )
  520.             END
  521.  
  522.             /* reset to last saved settings (ENVARC) */
  523.             WHEN (Upper(h.event) = "MUIPREFSLAST")
  524.             THEN DO
  525.                 Call LoadProject( "" )
  526.                 Call PrefsWindowSet()
  527.             END
  528.  
  529.             /* DISPLAY file */
  530.             WHEN (Upper(h.event) = "DO_DISPLAY")
  531.             THEN DO
  532.                 Call DoGhostscript( const.actionDisplay    )
  533.             END
  534.  
  535.             /* PRINT file */
  536.             WHEN (Upper(h.event) = "DO_PRINT")
  537.             THEN DO
  538.                 Call DoGhostscript( const.actionPrint )
  539.             END
  540.             
  541.             /* CONVERT file */
  542.             WHEN (Upper(h.event) = "DO_CONVERT")
  543.             THEN DO
  544.                 Call DoGhostscript( const.actionConvert    )
  545.             END
  546.  
  547.             /* CONVERT file */
  548.             WHEN (Upper(h.event) = "METHODCHANGE11111")
  549.             THEN DO
  550.                 Say "removing..." h.active
  551.                 Call DoMethod("muiSettingsDisplay", "InitChange")
  552.  
  553.                 IF h.active = 0
  554.                 THEN DO
  555.                     Call Remove("muiSD03")
  556.                     Call Add("muiSettingsDisplay", "muiSD02")
  557. /*
  558.                     Call DoMethod("muiSettingsDisplay", "SORT", "muiSD02", "DummyVSPACE")
  559. */
  560.                 END
  561.  
  562.                 IF h.active = 1
  563.                 THEN DO
  564.                     Call Remove("muiSD02")
  565.                     Call Add("muiSettingsDisplay", "muiSD03")
  566. /*
  567.                     Call DoMethod("muiSettingsDisplay", "SORT", "muiSD03", "DummyVSpace")
  568. */
  569.                 END
  570.  
  571.                 Call DoMethod("muiSettingsDisplay", "ExitChange")
  572.             END
  573.  
  574.  
  575.             /* enable/disable page settings */
  576.             WHEN (Upper(h.event) = "PSFILECHANGE")
  577.             THEN DO
  578.                 Call PrefsWindowGet( )
  579.                 file = GetGUIGadget("g_psfilename")
  580.                 IF IsPDF( file ) = const.bool.TRUE
  581.                 THEN DO
  582.                     Call Set("g_d_page", "DISABLED", 0)
  583.                     Call Set("g_p_page1", "DISABLED", 0)
  584.                     Call Set("g_p_page2", "DISABLED", 0)
  585.                     Call Set("g_c_page1", "DISABLED", 0)
  586.                     Call Set("g_c_page2", "DISABLED", 0)
  587.                 END
  588.                 ELSE DO
  589.                     Call Set("g_d_page", "DISABLED", 1)
  590.                     Call Set("g_p_page1", "DISABLED", 1)
  591.                     Call Set("g_p_page2", "DISABLED", 1)
  592.                     Call Set("g_c_page1", "DISABLED", 1)
  593.                     Call Set("g_c_page2", "DISABLED", 1)
  594.                 END
  595.             END
  596.  
  597.             /* correct "Ram Disk:" to "RAM:" for convertion files */
  598.             WHEN (Upper(h.event) = "CONVFILECHANGE")
  599.             THEN DO
  600.                 Call PrefsWindowGet( )
  601.                 file = GetGUIGadget("g_c_conv_file")
  602.                 IF Upper(Left(file, 9)) = "RAM DISK:"
  603.                 THEN DO
  604.                     file = "RAM:" || SubStr(file, 10)
  605.                     Call Set("g_c_conv_file", "CONTENTS", file)
  606.                 END
  607.             END
  608.  
  609.             /**/
  610.             OTHERWISE
  611.             DO
  612.                 Call dumpVar('h.event')
  613.             END
  614.  
  615.         END
  616.     END
  617. Return
  618. /* /// */
  619. /* /// HandleGSRunning( )
  620. */
  621. HandleGSRunning:
  622.     PARSE ARG action
  623.  
  624.     /* this is the standard cycle to handle an application */
  625.     sig_CTRL_C = 2**12
  626.  
  627.     /* create notification for TMP file */
  628.     tmpFileNotifyID = StartNotify(global.tmpFile)
  629.     tmpFileSignal    = NotifySignal(tmpFileNotifyID)
  630.     s = Or(sig_CTRL_C, tmpFileSignal)
  631.  
  632.     wantedBreaks = 0
  633.     maxBreak     = 3
  634.  
  635.     Call dumpVar('tmpFileNotifyID')
  636.     Call dumpVar('tmpFileSignal')
  637.  
  638.     /* open busy window */
  639.     SELECT
  640.         WHEN action = const.actionDisplay
  641.             THEN Call ActionWindowOpen("Displaying %i"|| file,"...")
  642.         WHEN action = const.actionPrint
  643.             THEN Call ActionWindowOpen("Printing %i"|| file,"...")
  644.         WHEN action = const.actionConvert
  645.             THEN Call ActionWindowOpen("Converting %i"|| file,"...")
  646.     END
  647.  
  648.     doit = 1
  649.     DO WHILE (doit = 1)
  650.  
  651.         h.event = ''
  652.         Call NewHandle("muiAPP", "H", s)
  653.  
  654.         IF ( and(h.signals, sig_CTRL_C) > 0 )
  655.         THEN DO
  656.             Call dumpText('CTRL C pressed -> exiting')
  657.             SIGNAL QUIT
  658.         END
  659.  
  660.         IF ( and(h.signals, tmpFileSignal) > 0 )
  661.         THEN DO
  662.             Call dumpText('TMP file has been deleted -> GS finished')
  663.             doit = 0
  664.         END
  665.  
  666.         IF Exists( global.tmpFile ) = 0
  667.         THEN doit = 0
  668.  
  669.  
  670.         /* check if TMP file still is present */
  671.         SELECT
  672.  
  673.             /* action window close */
  674.             WHEN (Upper(h.event) = "ACTION_QUIT") | (Upper(h.event) = "ACTION_CANCEL")
  675.             THEN DO
  676.                 wantedBreaksLeft = maxBreak - wantedBreaks - 1
  677.                 Call Set("actionInfo1", "CONTENTS", ParseText("%c%bsending BREAK to gs8 process...%n"))
  678.                 Call Set("actionInfo2", "CONTENTS", ParseText("%cpress "|| wantedBreaksLeft ||" more time(s) to cancel hard%n"))
  679.  
  680.                 /* just send a break and wait... */
  681.                 Call dumpText('sending BREAK to process '|| global.guiScriptProcess)
  682.                 Call System("C:BREAK "|| global.guiScriptProcess)
  683.                 /* if breaked more than "maxBreak" times -> hard break! */
  684.                 wantedBreaks = wantedBreaks + 1
  685.                 IF wantedBreaks > maxBreak
  686.                 THEN DO
  687.                     doit = 0
  688.                 END
  689.             END
  690.  
  691.             /**/
  692.             OTHERWISE
  693.             DO
  694.                 Call dumpVar('h.event')
  695.             END
  696.  
  697.         END
  698.     END
  699.  
  700.     Call ActionWindowClose()
  701.  
  702. Return
  703. /* /// */
  704.  
  705. /* /// SetDefaults()
  706. */
  707. SetDefaults:
  708.  
  709.     /* defaults needed in the program */
  710.     const.bool.0            = 'FALSE'
  711.     const.bool.1            = 'TRUE'
  712.     const.bool.TRUE          = 1
  713.     const.bool.FALSE         = 0
  714.     const.settingFileHandle    = "GS8FH"
  715.     const.settingFileName    = "ENV:gs8_GUIscript"
  716.  
  717.     const.Info.muiName            = 'GS8gui'
  718.     const.Info.muiVersion        = 'V0.06'
  719.     const.Info.muiAuthor        = 'Michael Merkel'
  720.     const.Info.muiCopy            = '©2003-04 Michael Merkel'
  721.     const.Info.muiDate            = '2004/01/06'
  722.     const.Info.muiPic            = 'PROGDIR:GS8gui.pic'
  723.     const.Info.muiDescription    = 'Graphical User Interace for Ghostscript8'
  724.     const.gs8                     = 'GS8:bin/gs_2n'
  725.     const.actionDisplay            = 'DISPLAY'
  726.     const.actionConvert            = 'CONVERT'
  727.     const.actionPrint            = 'PRINT'
  728.  
  729.     const.Gadget.Method            = "internal|external (bitmap)"
  730.  
  731.     /* globals */
  732.     IF Length(global.DEBUG) ~= 1
  733.     THEN global.DEBUG = 0
  734.  
  735.     global.guiAttrCount = 0
  736.     global.guiScriptFile        = 'T:GS8gui.bat'
  737.     global.tmpFile                = 'T:tmp'
  738.  
  739.     /* get tooltype for GS8 executable */
  740.     appPath = ProgramName("NOEXT")
  741.     Call GetToolType(appPath, "GS8", "global.gs8", const.gs8)
  742.  
  743.     Call dumpVar('global.gs8')
  744.  
  745. Return
  746. /* /// */
  747.  
  748. /* /// DoGhostscript( action )
  749. */
  750. DoGhostscript:
  751.     PROCEDURE EXPOSE global. const.
  752.     PARSE ARG action
  753.  
  754.     /* check for existing file first! */
  755.     Call PrefsWindowGet( )
  756.     file = GetGUIGadget("g_psfilename")
  757.     IF Exists(file) = 0
  758.     THEN DO
  759.         Call RMH_EasyRequest("Source file '"|| file ||"' not found!", "File not found", "Ok")
  760.         Return
  761.     END
  762.  
  763.     /* get unique process id */
  764.     global.tmpFile            = CreateTempFile()
  765.     global.guiScriptFile    = CreateTempFile()
  766.  
  767.     Call dumpVar('global.tmpFile')
  768.     Call dumpVar('global.guiScriptFile')
  769.  
  770.     Call SetAttr("muiWin", "SLEEP", const.bool.TRUE)
  771.  
  772.     SELECT
  773.         WHEN action = const.actionDisplay
  774.             THEN Call DoDisplay()
  775.         WHEN action = const.actionPrint
  776.             THEN Call DoPrint()
  777.         WHEN action = const.actionConvert
  778.             THEN Call DoConvert()
  779.     END
  780.  
  781.     /* wait and handle busy window */
  782.     Call HandleGSRunning( action )
  783.  
  784.     Call SetAttr("muiWin", "SLEEP", const.bool.FALSE)
  785.  
  786. Return
  787. /* /// */
  788. /* /// DoPrint()
  789. */
  790. DoPrint:
  791.     PROCEDURE EXPOSE global. const.
  792.  
  793.     SAY "Printing..."
  794.  
  795.     Call PrefsWindowGet( )
  796.  
  797.     file    = GetGUIGadget("g_psfilename")
  798.     dpi         = GetGUIGadget("g_p_dpi")
  799.     page1    = Right("000"|| GetGUIGadget("g_p_page1"), 3)
  800.     page2    = Right("000"|| GetGUIGadget("g_p_page2"), 3)
  801.     device    = GetGUIGadget("g_p_device")
  802.  
  803.  
  804.     IF device = 0
  805.     THEN device = "tp24"
  806.     IF device = 1
  807.     THEN device = "tp8g"
  808.     IF device = 2
  809.     THEN device = "tp1"
  810.  
  811.     SAY dpi device page1 page2
  812.  
  813.     Call Open(const.settingFileHandle, global.guiScriptFile, "W")
  814.  
  815.     Call WriteLN(const.settingFileHandle, 'SET print 0')
  816.     Call WriteLN(const.settingFileHandle, 'SET window 1')
  817.     Call WriteLN(const.settingFileHandle, 'STACK 200000')
  818.     Call WriteLN(const.settingFileHandle, "FAILAT 9999") /* ignore errors */
  819.     
  820.     /* build command line... */
  821.     command = global.gs8
  822.     command = command || ' -sDEVICE='|| device
  823.     IF ( dpi > 0 )
  824.     THEN command = command || ' -r'|| dpi
  825.  
  826.     IF IsPDF( file ) = const.bool.TRUE
  827.     THEN DO
  828.         command = command || ' -dFirstPage='|| page1
  829.         command = command || ' -dLastPage='|| page2
  830.     END
  831.     command = command || ' -dBATCH -dNOPAUSE -q'
  832.     command = command || ' "'|| file || '"'
  833.  
  834.     Call DumpVar( 'command' )
  835.  
  836.     Call WriteLN(const.settingFileHandle, command)
  837.     Call WriteLN(const.settingFileHandle, "DELETE >NIL: FORCE " || global.tmpFile)
  838.  
  839.     Call Close(const.settingFileHandle)
  840.  
  841.     Call System("C:Protect "|| global.guiScriptFile ||" +es")
  842.     Call System("C:Run C:Execute "|| global.guiScriptFile,,'CommandResult')
  843.  
  844.     /* remember process id: "[CLI xxx]" */
  845.     global.guiScriptProcess = Compress( CommandResult, " [CLI]")
  846.     Call dumpVar( 'global.guiScriptProcess' )
  847.  
  848. Return
  849. /* /// */
  850. /* /// DoDisplay()
  851. */
  852. DoDisplay:
  853.     PROCEDURE EXPOSE global. const.
  854.  
  855.     SAY "Displaying..."
  856.  
  857.     Call PrefsWindowGet( )
  858.     
  859.     method     = GetGUIGAdget("g_d_method")
  860.     file    = GetGUIGadget("g_psfilename")
  861.     dpi         = GetGUIGadget("g_d_dpi")
  862.     device    = GetGUIGadget("g_d_device")
  863.  
  864.     IF ( method = 0 )
  865.     THEN Call DoDisplayInternal( )
  866.     ELSE Call DoDisplayExternal( )
  867.  
  868. Return
  869. /* /// */
  870. /* /// DoDisplayInternal()
  871. */
  872. DoDisplayInternal:
  873.     PROCEDURE EXPOSE global. const.
  874.  
  875.     SAY "...internally"
  876.  
  877.     Call PrefsWindowGet( )
  878.     
  879.     file        = GetGUIGadget("g_psfilename")
  880.     dpi             = GetGUIGadget("g_d_dpi")
  881.     device        = GetGUIGadget("g_d_device")
  882.     page        = Right("000"|| GetGUIGadget("g_d_page"), 3)
  883.     screen        = GetGUIGadget("g_d_screen")
  884.     screenwb    = GetGUIGadget("g_d_screenwb")
  885.  
  886.     IF device = 0
  887.     THEN device = "whoosh24"
  888.     IF device = 1
  889.     THEN device = "whooshg"
  890.     IF device = 2
  891.     THEN device = "whoosh1"
  892.  
  893.     SAY file dpi device page
  894.  
  895.     Call Open(const.settingFileHandle, global.guiScriptFile, "W")
  896.  
  897.     Call WriteLN(const.settingFileHandle, 'SET print 0')
  898.     Call WriteLN(const.settingFileHandle, 'SET window 1')
  899.     IF (screen = 0)
  900.     THEN DO
  901.         Call WriteLN(const.settingFileHandle, 'SET whooshsuper 1')
  902.     END
  903.     ELSE DO
  904.         Call WriteLN(const.settingFileHandle, 'SET whooshsuper 0')
  905.         IF (screenwb = 0)
  906.         THEN DO
  907.             Call WriteLN(const.settingFileHandle, 'SET whooshwbres 0')
  908.         END
  909.         ELSE DO
  910.             Call WriteLN(const.settingFileHandle, 'SET whooshwbres 1')
  911.         END
  912.     END
  913.  
  914. /*
  915. set whooshscreen 102400 ; set custom screen to a specific screenmode
  916. set whooshwbres 1; custom screen to use same screenmode as workbench
  917. set whooshsuper 1 ; WB viewing on
  918. set whooshsuper 0 ; WB viewing off == custom screen viewer on
  919. */
  920.     
  921.     Call WriteLN(const.settingFileHandle, 'STACK 200000')
  922.     Call WriteLN(const.settingFileHandle, "FAILAT 9999") /* ignore errors */
  923.  
  924.     /* build command line... */
  925.     command = global.gs8
  926.     command = command || ' -sDEVICE='|| device
  927.     IF ( dpi > 0 )
  928.     THEN command = command || ' -r'|| dpi
  929.  
  930.     IF IsPDF( file ) = const.bool.TRUE
  931.     THEN DO
  932.         command = command || ' -dFirstPage='|| page
  933.         command = command || ' -dLastPage='|| page
  934.     END
  935.     command = command || ' -dBATCH -dNOPAUSE -q'
  936.     command = command || ' "'|| file || '"'
  937.  
  938.     Call DumpVar( 'command' )
  939.  
  940.     Call WriteLN(const.settingFileHandle, command)
  941.     Call WriteLN(const.settingFileHandle, "DELETE >NIL: FORCE " || global.tmpFile)
  942.  
  943.     Call Close(const.settingFileHandle)
  944.     Call System("C:Protect "|| global.guiScriptFile ||" +es")
  945.     Call System("C:Run C:Execute "|| global.guiScriptFile,,'CommandResult')
  946.  
  947.     /* remember process id: "[CLI xxx]" */
  948.     global.guiScriptProcess = Compress( CommandResult, " [CLI]")
  949.     Call dumpVar( 'global.guiScriptProcess' )
  950.  
  951. Return
  952. /* /// */
  953. /* /// DoDisplayExternal()
  954. */
  955. DoDisplayExternal:
  956.     PROCEDURE EXPOSE global. const.
  957.  
  958.     SAY ".. externally"
  959.  
  960.     Call PrefsWindowGet( )
  961.     
  962.     file    = GetGUIGadget("g_psfilename")
  963.     dpi         = GetGUIGadget("g_d_dpi")
  964.     page    = Right("000"|| GetGUIGadget("g_d_page"), 3)
  965.     viewer    = GetGUIGadget("g_d_ex_viewer")
  966.     format    = GetGUIGadget("g_d_bm_format")     /*"JPEG|PNG|TIFF"*/
  967.     quality    = GetGUIGadget("g_d_bm_quality")     /*"24 bit color|8 bit grey|1 bit b/w" */
  968.     path    = GetGUIGadget("g_d_bm_path")
  969.  
  970.     SAY file dpi viewer format quality path
  971.  
  972.     SELECT
  973.         WHEN ( format = 0 )
  974.             THEN
  975.                 SELECT
  976.                     WHEN ( quality = 1 )
  977.                         THEN device = "jpeggray"
  978.                     OTHERWISE
  979.                         device = "jpeg"
  980.                 END
  981.         WHEN ( format = 1 )
  982.             THEN
  983.                 SELECT
  984.                     WHEN ( quality = 0 )
  985.                         THEN device = "png16m"
  986.                     WHEN ( quality = 1 )
  987.                         THEN device = "png16"
  988.                     WHEN ( quality = 2 )
  989.                         THEN device = "png256"
  990.                 END
  991.         OTHERWISE
  992.             device = "tifflzw"
  993.     END
  994.     outputfile = AddPart(path, "GS8VIEW.tmp")
  995.  
  996.     SAY device outputfile
  997.  
  998.     Call Open(const.settingFileHandle, global.guiScriptFile, "W")
  999.  
  1000.     Call WriteLN(const.settingFileHandle, 'SET print 1')
  1001.     Call WriteLN(const.settingFileHandle, 'SET window 0')
  1002.     Call WriteLN(const.settingFileHandle, 'STACK 200000')
  1003.     Call WriteLN(const.settingFileHandle, "FAILAT 9999") /* ignore errors */
  1004.  
  1005.  
  1006.     /* build command line... */
  1007.     command = global.gs8
  1008.     command = command || ' -sDEVICE='|| device
  1009.     IF ( dpi > 0 )
  1010.     THEN command = command || ' -r'|| dpi
  1011.  
  1012.     IF IsPDF( file ) = const.bool.TRUE
  1013.     THEN DO
  1014.         command = command || ' -dFirstPage='|| page
  1015.         command = command || ' -dLastPage='|| page
  1016.     END
  1017.     command = command || ' -sOutputFile='|| outputfile
  1018.     command = command || ' -dBATCH -dNOPAUSE -q'
  1019.     command = command || ' "'|| file || '"'
  1020.  
  1021.     Call DumpVar( 'command' )
  1022.  
  1023.     Call WriteLN(const.settingFileHandle, command)
  1024.  
  1025.     /* external viewer */
  1026.     command = viewer || " " || outputfile
  1027.     Call WriteLN(const.settingFileHandle, command)
  1028.     Call WriteLN(const.settingFileHandle, "DELETE >NIL: FORCE " || global.tmpFile)
  1029.  
  1030.     Call Close(const.settingFileHandle)
  1031.     Call System("C:Protect "|| global.guiScriptFile ||" +es")
  1032.     Call System("C:Run C:Execute "|| global.guiScriptFile,,'CommandResult')
  1033.  
  1034.     /* remember process id: "[CLI xxx]" */
  1035.     global.guiScriptProcess = Compress( CommandResult, " [CLI]")
  1036.     Call dumpVar( 'global.guiScriptProcess' )
  1037.  
  1038. Return
  1039. /* /// */
  1040. /* /// DoConvert()
  1041. */
  1042. DoConvert:
  1043.     PROCEDURE EXPOSE global. const.
  1044.  
  1045.     SAY "Converting..."
  1046.  
  1047.     Call PrefsWindowGet( )
  1048.  
  1049.     file        = GetGUIGadget("g_psfilename")
  1050.     dpi             = GetGUIGadget("g_c_dpi")
  1051.     page1        = Right("000"|| GetGUIGadget("g_c_page1"), 3)
  1052.     page2        = Right("000"|| GetGUIGadget("g_c_page2"), 3)
  1053.     device        = GetGUIGadget("g_c_device")
  1054.     convFile    = GetGUIGadget("g_c_conv_file")
  1055.     
  1056.     Call ActionWindowOpen("Converting %i"|| file)
  1057.  
  1058.     /*
  1059.     muiSC02.1                    = MakeObj("g_c_device","Cycle", "PDF|EPS|PS|TIFF|PNG|JPEG", "D", "0")
  1060.     */
  1061.  
  1062.     IF device = 0
  1063.     THEN device = "pdfwrite"
  1064.     IF device = 1
  1065.     THEN device = "epswrite"
  1066.     IF device = 2
  1067.     THEN device = "pswrite"
  1068.     IF device = 3
  1069.     THEN device = "tifflzw"
  1070.     IF device = 4
  1071.     THEN device = "png16m"
  1072.     IF device = 5
  1073.     THEN device = "jpeg"
  1074.  
  1075.     SAY dpi device page1 page2 convFile
  1076.  
  1077.     Call Open(const.settingFileHandle, global.guiScriptFile, "W")
  1078.  
  1079.     Call WriteLN(const.settingFileHandle, 'SET print 0')
  1080.     Call WriteLN(const.settingFileHandle, 'SET window 1')
  1081.     Call WriteLN(const.settingFileHandle, 'STACK 200000')
  1082.     Call WriteLN(const.settingFileHandle, "FAILAT 9999") /* ignore errors */
  1083.  
  1084.     /* build command line... */
  1085.     command = global.gs8
  1086.     command = command || ' -sDEVICE='|| device
  1087.     IF ( dpi > 0 )
  1088.     THEN command = command || ' -r'|| dpi
  1089.  
  1090.     IF IsPDF( file ) = const.bool.TRUE
  1091.     THEN DO
  1092.         command = command || ' -dFirstPage='|| page1
  1093.         command = command || ' -dLastPage='|| page2
  1094.     END
  1095.     command = command || ' -sOutputFile='|| convFile
  1096.     command = command || ' -dBATCH -dNOPAUSE -q'
  1097.     command = command || ' "'|| file || '"'
  1098.  
  1099.     Call DumpVar( 'command' )
  1100.  
  1101.     Call WriteLN(const.settingFileHandle, command)
  1102.     Call WriteLN(const.settingFileHandle, "DELETE >NIL: FORCE " || global.tmpFile)
  1103.  
  1104.     Call Close(const.settingFileHandle)
  1105.     Call System("C:Protect "|| global.guiScriptFile ||" +es")
  1106.     Call System("C:Run C:Execute "|| global.guiScriptFile,,'CommandResult')
  1107.  
  1108.     /* remember process id: "[CLI xxx]" */
  1109.     global.guiScriptProcess = Compress( CommandResult, " [CLI]")
  1110.     Call dumpVar( 'global.guiScriptProcess' )
  1111.  
  1112. Return
  1113. /* /// */
  1114.  
  1115. /* /// name = GetFileName()
  1116. */
  1117. GetFileName:
  1118.     PROCEDURE EXPOSE global. const.
  1119.  
  1120.     name = ''
  1121.  
  1122.     Call System('RequestFile DRAWER="SYS:Prefs/presets" FILE="GS8gui.prefs" PATTERN="#?.prefs"',, "name")
  1123.     IF name ~= ''
  1124.     THEN DO
  1125.         /* remove "s */
  1126.         name = Substr(name, 2, Length(name) - 3)
  1127.     END
  1128.  
  1129. Return name
  1130. /* /// */
  1131. /* /// bool = IsPDF( filename )
  1132. */
  1133. IsPDF:
  1134.     PROCEDURE EXPOSE global. const.
  1135.     PARSE ARG fileName
  1136.  
  1137.     ispdf = const.bool.FALSE
  1138.     
  1139.     file= Trim(fileName)
  1140.     IF Upper(Right(file, 4)) = ".PDF"
  1141.     THEN ispdf = const.bool.TRUE
  1142.     ELSE ispdf = const.bool.FALSE
  1143. Return ispdf
  1144. /* /// */
  1145.  
  1146. /* /// LoadProject( project )
  1147. */
  1148. LoadProject:
  1149.     PROCEDURE EXPOSE global. const.
  1150.     PARSE ARG project
  1151.  
  1152.     IF ( project = "" )
  1153.     THEN Call DoMethod("muiAPP", "LOAD", "ENVARC")
  1154.     ELSE Call DoMethod("muiAPP", "LOAD", project)
  1155.  
  1156. Return
  1157. /* /// */
  1158. /* /// SaveProject( project )
  1159. */
  1160. SaveProject:
  1161.     PROCEDURE EXPOSE global. const.
  1162.  
  1163.     PARSE ARG project
  1164.  
  1165.     IF ( project = "" )
  1166.     THEN Call DoMethod("muiAPP", "SAVE", "ENVARC")
  1167.     ELSE Call DoMethod("muiAPP", "SAVE", project)
  1168. Return
  1169. /* /// */
  1170.  
  1171. /* /// AddGUIGadget( gadgetName, gadgetID, attrType )
  1172. */
  1173. AddGUIGadget:
  1174.     PROCEDURE EXPOSE global. const.
  1175.  
  1176.     PARSE ARG gadgetName,gadgetID,attrType
  1177.  
  1178.     gadgetName = Upper(gadgetName)
  1179.  
  1180.     n = global.guiAttrCount
  1181.  
  1182.     global.guiAttr.n        = gadgetName
  1183.     global.guiAttr.n.attr    = attrType
  1184.  
  1185.     global.guiAttrCount = n + 1
  1186.  
  1187.     /* cycle chain */
  1188.     Call Set(gadgetName, "CYCLECHAIN", 1)
  1189.  
  1190.     /* object id if wanted */
  1191.     id = Right("0000"||gadgetID, 4)
  1192.  
  1193. /*
  1194.  
  1195.     IF id ~= "0000"
  1196.     THEN Call Set( gadgetName, "ObjectID", gadgetID )
  1197. */
  1198.  
  1199. Return
  1200. /* /// */
  1201. /* /// SetGUIGadget( gadgetName, attrValue )
  1202. */
  1203. SetGUIGadget:
  1204.     PROCEDURE EXPOSE global. const.
  1205.  
  1206.     PARSE ARG gadgetName,attrValue
  1207.  
  1208.     gadgetName = Upper(gadgetName)
  1209.  
  1210.     n = global.guiAttrCount
  1211.     DO k = 0 TO n
  1212.         IF global.guiAttr.k = gadgetName
  1213.         THEN DO
  1214.             global.guiAttr.k.value = attrValue
  1215.             Return
  1216.         END
  1217.     END
  1218.     Signal ERROR
  1219. Return
  1220. /* /// */
  1221. /* /// attrValue = GetGUIGadget( gadgetName )
  1222. */
  1223. GetGUIGadget:
  1224.     PROCEDURE EXPOSE global. const.
  1225.  
  1226.     PARSE ARG gadgetName
  1227.  
  1228.     gadgetName = Upper(gadgetName)
  1229.  
  1230.     n = global.guiAttrCount
  1231.     DO k = 0 TO n
  1232.         IF global.guiAttr.k = gadgetName
  1233.         THEN DO
  1234.             Return global.guiAttr.k.value
  1235.         END
  1236.     END
  1237.     Signal ERROR
  1238. Return 0
  1239. /* /// */
  1240.  
  1241. /* /// PrefsWindowGet()
  1242. */
  1243. PrefsWindowGet:
  1244.     PROCEDURE EXPOSE global. const.
  1245.  
  1246.     /* read everything at once */
  1247.     Call MultiGetAttr(global.guiAttr)
  1248. Return
  1249. /* /// */
  1250. /* /// PrefsWindowSet()
  1251. */
  1252. PrefsWindowSet:
  1253.     PROCEDURE EXPOSE global. const.
  1254.  
  1255.     /* set everything at once */
  1256.     Call MultiSetAttr(global.guiAttr)
  1257. Return
  1258. /* /// */
  1259.  
  1260. /* /// ActionWindowOpen()
  1261. */
  1262. ActionWindowOpen:
  1263.     PROCEDURE EXPOSE global. const.
  1264.     PARSE ARG actionInfo1,actionInfo2
  1265.  
  1266.     Call Set("actionInfo1", "CONTENTS", ParseText("%c%b"|| actionInfo1 ||"%n"))
  1267.     Call Set("actionInfo2", "CONTENTS", ParseText("%c%b"|| actionInfo2 ||"%n"))
  1268.     Call Set("actionWin","open",1)
  1269.  
  1270. Return
  1271. /* /// */
  1272. /* /// ActionWindowClose()
  1273. */
  1274. ActionWindowClose:
  1275.     Call set("actionWin", "open", 0)
  1276. Return
  1277. /* /// */
  1278.  
  1279. /* /// CleanUp()
  1280. */
  1281. CleanUp:
  1282.     PROCEDURE EXPOSE global. const.
  1283.  
  1284.     /*
  1285.     ** Close busy requester, clean up and leave program
  1286.     ** ------------------------------------------------
  1287.     */
  1288.  
  1289.     IF global.ActiveWin = global.TRUE
  1290.     THEN Call Dispose("muiWin")
  1291.  
  1292.     IF global.ActiveApp = global.TRUE
  1293.     THEN Call Dispose("muiApp")
  1294.  
  1295. EXIT
  1296. /* /// */
  1297.  
  1298. /* /// ErrorRequester( text )
  1299. */
  1300. ErrorRequester: PROCEDURE
  1301.     PARSE ARG meldung
  1302.  
  1303.     /*
  1304.     ** Convert to multiple lines
  1305.     */
  1306.  
  1307.     _num       = 1
  1308.     mLines.num = _num
  1309.     mLines.0   = meldung
  1310.  
  1311.     DO FOREVER
  1312.         _prev = _num-1
  1313.         pos = Index(mLines._prev, '|')
  1314.         IF (pos = 0)
  1315.         THEN LEAVE
  1316.  
  1317.         mLines._num  = SubStr(mLines._prev, pos+1)
  1318.         mLines._prev = Left(mLines._prev, pos-1)
  1319.         _num = _num + 1
  1320.     END
  1321.     mLines.num = _num
  1322.  
  1323.     say "*-------------------------------------------*"
  1324.     l = 0
  1325.     DO kk = 0 TO mLines.num - 1
  1326.         IF (l < Length(mLines.kk) * 8)
  1327.         THEN l = Length(mLines.kk) * 8
  1328.         Say mLines.kk
  1329.     END
  1330.     say "*-------------------------------------------*"
  1331.  
  1332.     Call EasyRequest(meldung, muiName, 'Quit')
  1333.  
  1334. RETURN
  1335. /* /// */
  1336. /* /// ON ERROR/FAILURE
  1337. */
  1338. Error:
  1339. Failure:
  1340.     f = rc
  1341.     str = "Command in line "|| sigl || " throws RC="|| f
  1342.  
  1343.     Call ErrorRequester(str)
  1344.     Signal QUIT
  1345. Exit
  1346. /* /// */
  1347. /* /// ON HALT
  1348. */
  1349. Halt:
  1350.     Signal Quit
  1351. Exit
  1352. /* /// */
  1353. /* /// ON NOVALUE
  1354. */
  1355. NoValue:
  1356.     f = rc
  1357.     str = "Error in line "|| sigl || "used uninitialized variable!"
  1358.  
  1359.     Call ErrorRequester(str)
  1360.  
  1361.     Signal QUIT
  1362. Exit
  1363. /* /// */
  1364. /* /// ON RXMUIERROR
  1365. */
  1366. RxMUIError:
  1367.     IF Symbol('RxMUIError')=='VAR'
  1368.     THEN RxMUIErrorMore=', More:' RxMUIError
  1369.     ELSE RxMUIErrorMore=''
  1370.  
  1371.     f = rc
  1372.     str = "Syntax Error in line "|| sigl || " -- rxMuiError "|| arg(1) ||": " GetRxMUIString(arg(1))RxMUIErrorMore
  1373.  
  1374.     Call ErrorRequester(str)
  1375.  
  1376.     Signal Quit
  1377. Exit
  1378. /* /// */
  1379. /* /// ON SYNTAX
  1380. */
  1381. SYNTAX:
  1382.     f = rc
  1383.     str = "Syntax Error in line "|| sigl || " -- "|| f ||":" ErrorText(f)
  1384.  
  1385.     Call ErrorRequester(str)
  1386.  
  1387.     Signal QUIT
  1388. EXIT
  1389. /* /// */
  1390. /* /// ON QUIT
  1391. */
  1392. Quit:
  1393.     Call CleanUp()
  1394. exit
  1395. /* /// */
  1396. /* /// dumpVar( VarName )
  1397. */
  1398. dumpVar:
  1399.     PARSE ARG vn
  1400.  
  1401.     IF global.DEBUG > 0
  1402.     THEN DO
  1403.         INTERPRET 't = "'|| vn || ' = "'|| vn
  1404.         Call dumpText(t)
  1405.     END
  1406. Return 0
  1407. /* /// */
  1408. /* /// dumpText( text )
  1409. */
  1410. dumpText:
  1411.     PARSE ARG text
  1412.  
  1413.     IF global.DEBUG > 0
  1414.     THEN DO
  1415.         Say text
  1416.         IF (global.debug = 2)
  1417.         THEN DO
  1418.             IF (global.DumpFile = '')
  1419.             THEN DO
  1420.                 global.DumpFile = 'DumpFile'
  1421.                 Call Open("global.DumpFile", "CON:0/0/1000/100/"|| muiName ||" - DEBUG/CLOSE/WAIT","W")
  1422.             END
  1423.             IF global.DumpFile ~= ''
  1424.             THEN DO
  1425.                 Call WriteLN("global.DumpFile", text)
  1426.             END
  1427.         END
  1428.     END
  1429. Return 0
  1430. /* /// */
  1431.  
  1432. /* /// pos = GetPosString( string, value )
  1433. */
  1434. GetPosString: PROCEDURE
  1435.     PARSE ARG text,value
  1436.     /* "internal|external (bitmap)"    */
  1437. Return pos
  1438. /* /// */
  1439.  
  1440.